Skip to content

Conversation

@pschiel
Copy link
Contributor

@pschiel pschiel commented Jan 3, 2026

Summary

This fix solves a whole series of bugs, resulting from filepath issues with backslashes occuring on Windows.

Solution: normalize all internal paths to forward slashes using centralized Filesystem wrappers

Why this works: all win32 shells work with forward slash paths, this is de-facto industry standard (git, vscode, cmake, ... all use this pattern)

Observed issues

git rev-parse --show-toplevel returns E:/x/y forward slash format → worktree/directory mismatch
path.resolve(), path.relative(), realpathSync.native(), realpath (bash) break with git bash paths (various issues)
/d/x within C drive (/c/) results in things like C:\d\x
❌ relative paths not working like expected using cross-drive
contains logic not working → issues with permission system and external_directory
/tmp inside git bash is something else outside of it
❌ tools break using backslash paths (some backslashes get "eaten")
❌ escaping hell for agents → requires double/quadruple escaping
❌ observed in all win32 native shells (git bash, cmd, powershell/pwsh)
❌ few issues in app/desktop (wrong filepath splits/usage)

Tested with fix

✅ local test suite succeeds now with 100% (bun test in packages/opencode)
✅ all possible path variants (C:\a\b, C:/a/b, /c/a/b, /cygdrive/c/a/b) are normalized into C:/a/b format
✅ full functionality of all tools (ENOENT errors gone, permissions, relative paths, external directory, LSP)
✅ worktree/sandbox handling correct
✅ tested TUI and desktop

How to reproduce/test

  • test suite
  • running prompts with various problematic/mixed filepaths (see attached md example)

Notes

A few more places would require normalization - but they're unused/dead code (should be removed):

  • packages/ui/src/context/sync.tsx line 16 absolute()
  • packages/ui/src/context/local.tsx line 392, 420, 455, 546 - file tree operations (no file tree used)

@pschiel pschiel force-pushed the windows-posix-paths branch 2 times, most recently from 032638f to 61531f5 Compare January 9, 2026 20:17
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Hey! Your PR title (feat) support MSYS forward slashes with experimental flag doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@pschiel pschiel force-pushed the windows-posix-paths branch 3 times, most recently from adf2edd to 9b205c2 Compare January 11, 2026 04:37
@pschiel pschiel changed the title (feat) support MSYS forward slashes with experimental flag feat: support MSYS forward slashes with experimental flag Jan 11, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@pschiel pschiel force-pushed the windows-posix-paths branch from 9b205c2 to bef6a68 Compare January 11, 2026 17:38
@Hona Hona self-requested a review January 11, 2026 20:25
@Hona
Copy link
Collaborator

Hona commented Jan 11, 2026

This sounds perfect @pschiel

If you can get it ready and finish the cleanup you said I can test and approve.

Btw don't put it behind an experimental flag. We'll ship once it's working.

@pschiel pschiel force-pushed the windows-posix-paths branch 4 times, most recently from 767f78b to ba251fb Compare January 15, 2026 21:49
@pschiel pschiel changed the title feat: support MSYS forward slashes with experimental flag fix(windows): comprehensive path handling fixes for MSYS/Git Bash compatibility Jan 15, 2026
@pschiel pschiel changed the title fix(windows): comprehensive path handling fixes for MSYS/Git Bash compatibility fix(windows): path handling fixes for MSYS/Git Bash compatibility Jan 16, 2026
@pschiel pschiel force-pushed the windows-posix-paths branch from ba251fb to aaa0f60 Compare January 17, 2026 03:25
@@ -1 +1 @@
../../ui/src/custom-elements.d.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi this is a symlink.
on windows its disabled by default

enable it with

git config core.symlinks true

then recheckout all the files with

git checkout -- .

obviously that would reset any changes so stash/commit first.
that will fix the typecheck too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was intentional, as this requires admin permissions on windows.

thoughts: changing symlink into export statement in 2 files is worth it for that (the other ~70 symlinks are fonts/images and not affected by TS parsing)

Copy link
Contributor

@neriousy neriousy Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this would've worked keeping as a simlink

/// <reference path="../../ui/src/custom-elements.d.ts" />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neriousy I went by this https://typescript-eslint.io/rules/triple-slash-reference/ which mentions triple slash being discouraged in modern ES6, and a rule for it.

please feel free to change, it was just so typecheck and tests run without errors, in a win32 environment

@pschiel pschiel force-pushed the windows-posix-paths branch 4 times, most recently from 5d5db7d to 62152d4 Compare January 17, 2026 07:42
@pschiel pschiel force-pushed the windows-posix-paths branch from 62152d4 to 30a54ce Compare January 17, 2026 20:51
@pschiel pschiel marked this pull request as ready for review January 17, 2026 21:19
@pschiel pschiel requested a review from adamdotdevin as a code owner January 17, 2026 21:19
@pschiel pschiel changed the title fix(windows): path handling fixes for MSYS/Git Bash compatibility fix(windows): path handling fixes for Windows Jan 17, 2026
@pschiel
Copy link
Contributor Author

pschiel commented Jan 17, 2026

@Hona am through with it now, tidied up and ready to review

@neriousy
Copy link
Contributor

Oh yeah, I was tackling it also today. Thought setting the cwd for the desktop app would be good when switching projects, but then you can switch the project with a session running in the background and it wouldn't work.

I also realized that you'd need to refactor a lot of the app and this PR does it, relatively good.

@neriousy
Copy link
Contributor

This would fix #9077 for example

@pschiel
Copy link
Contributor Author

pschiel commented Jan 17, 2026

Oh yeah, I was tackling it also today. Thought setting the cwd for the desktop app would be good when switching projects, but then you can switch the project with a session running in the background and it wouldn't work.

I also realized that you'd need to refactor a lot of the app and this PR does it, relatively good.

it's not yet documented - but that's what the "sandboxes" do. a worktree is the root of your git repo/worktree, a sandbox is a different directory inside. In the UI you see already the sandboxes, but they aren't explained, you don't see the path - looks like work in progress?

@Hona Hona self-assigned this Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants